package com.barry.oscheckpoint;

import java.io.*;

import android.os.Environment;

public class ReadCSV 
{
	
 public static void ReadOSGridCSVFile(String fileName)
  {
  try{
  // Open the file that is the first 
  // command line parameter
  FileInputStream fstream = new FileInputStream(Environment.getExternalStorageDirectory().getPath() + "/OSCheckPoint/" + fileName + ".csv");
  // Get the object of DataInputStream
  DataInputStream in = new DataInputStream(fstream);
  BufferedReader br = new BufferedReader(new InputStreamReader(in));
  String strLine;
  WriteXMLFile.CreateDocAndRootNode();
  //Read File Line By Line
  while ((strLine = br.readLine()) != null)   {
	  String[] array = strLine.split("\\,"); //[0] OSGrid, [1] Label
	  WriteXMLFile.CreateCheckPoint(array);
  }
  WriteXMLFile.WriteXML( fileName + ".xml");
  //Close the input stream
  in.close();
    }
  catch (Exception e){//Catch exception if any
  System.err.println("Error: " + e.getMessage());
  }
  }
}